var o, X, Y;
document.getElementById('box').onmousedown = function (e) {
  o = this;
  e = e || window.event;
  X = e.clientX - parseInt(o.style.left);
  Y = e.clientY - parseInt(o.style.top);
}
document.getElementById('box1').onmousedown = function (e) {
  o = this;
  e = e || window.event;
  X = e.clientX - parseInt(o.style.left);
  Y = e.clientY - parseInt(o.style.top);
}
document.onmousemove = function (e) {
  if (!o) {
    return;
  }
  e = e || window.event;
  o.style.left = e.clientX - X + "px";
  o.style.top = e.clientY - Y + "px";
}
document.onmouseup = function () {
  o = "";
}